using System;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace RiceShop.Models
{
    /// <summary>
    /// 订单实体
    /// </summary>
    [Table("Order")]
    public class Order
    {
        /// <summary>
        /// 订单ID
        /// </summary>
        [Key]
        public long Id { get; set; }

        /// <summary>
        /// 订单编号
        /// </summary>
        [Required]
        [StringLength(50)]
        public string OrderNo { get; set; } = string.Empty;

        /// <summary>
        /// 用户ID
        /// </summary>
        public long UserId { get; set; }

        /// <summary>
        /// 收货人姓名
        /// </summary>
        [Required]
        [StringLength(20)]
        public string ReceiverName { get; set; } = string.Empty;

        /// <summary>
        /// 收货人电话
        /// </summary>
        [Required]
        [StringLength(20)]
        public string PhoneNumber { get; set; } = string.Empty;

        /// <summary>
        /// 省份
        /// </summary>
        [Required]
        [StringLength(20)]
        public string Province { get; set; } = string.Empty;

        /// <summary>
        /// 城市
        /// </summary>
        [Required]
        [StringLength(20)]
        public string City { get; set; } = string.Empty;

        /// <summary>
        /// 区县
        /// </summary>
        [Required]
        [StringLength(20)]
        public string District { get; set; } = string.Empty;

        /// <summary>
        /// 详细地址
        /// </summary>
        [Required]
        [StringLength(100)]
        public string DetailAddress { get; set; } = string.Empty;

        /// <summary>
        /// 商品总价
        /// </summary>
        [Column(TypeName = "decimal(18,2)")]
        public decimal TotalAmount { get; set; }

        /// <summary>
        /// 运费
        /// </summary>
        [Column(TypeName = "decimal(18,2)")]
        public decimal Freight { get; set; }

        /// <summary>
        /// 优惠金额
        /// </summary>
        [Column(TypeName = "decimal(18,2)")]
        public decimal DiscountAmount { get; set; }

        /// <summary>
        /// 实付金额
        /// </summary>
        [Column(TypeName = "decimal(18,2)")]
        public decimal PayAmount { get; set; }

        /// <summary>
        /// 运费
        /// </summary>
        [Column(TypeName = "decimal(18,2)")]
        public decimal FreightFee { get; set; }

        /// <summary>
        /// 订单状态
        /// </summary>
        public OrderStatus Status { get; set; } = OrderStatus.Pending;

        /// <summary>
        /// 状态描述
        /// </summary>
        [StringLength(50)]
        public string? StatusDesc { get; set; }

        /// <summary>
        /// 收货地址ID
        /// </summary>
        public long AddressId { get; set; }

        /// <summary>
        /// 物流单号
        /// </summary>
        [StringLength(50)]
        public string? LogisticsNo { get; set; }

        /// <summary>
        /// 物流公司
        /// </summary>
        [StringLength(50)]
        public string? LogisticsCompany { get; set; }

        /// <summary>
        /// 支付时间
        /// </summary>
        public DateTime? PayTime { get; set; }

        /// <summary>
        /// 发货时间
        /// </summary>
        public DateTime? ShipTime { get; set; }

        /// <summary>
        /// 完成时间
        /// </summary>
        public DateTime? CompleteTime { get; set; }

        /// <summary>
        /// 支付方式(1:微信支付 2:支付宝支付)
        /// </summary>
        public byte PaymentType { get; set; }

        /// <summary>
        /// 来源(1:购物车 2:立即购买)
        /// </summary>
        public byte Source { get; set; }

        /// <summary>
        /// 优惠券ID
        /// </summary>
        public long? CouponId { get; set; }

        /// <summary>
        /// 微信支付交易号
        /// </summary>
        [StringLength(50)]
        public string? TransactionId { get; set; }

        /// <summary>
        /// 订单备注
        /// </summary>
        [StringLength(200)]
        public string? Remark { get; set; }

        /// <summary>
        /// 创建时间
        /// </summary>
        public DateTime CreateTime { get; set; } = DateTime.Now;

        /// <summary>
        /// 更新时间
        /// </summary>
        public DateTime? UpdateTime { get; set; }

        /// <summary>
        /// 订单商品列表
        /// </summary>
        public virtual ICollection<OrderGoods> Items { get; set; } = new List<OrderGoods>();

        /// <summary>
        /// 订单评论列表
        /// </summary>
        public virtual ICollection<Comment> Comments { get; set; } = new List<Comment>();

        /// <summary>
        /// 关联的用户
        /// </summary>
        public virtual User User { get; set; } = null!;



    }
}